<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="__static__/admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="__static__/admin/css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__static__/admin/js/jquery.js"></script>
<script type="text/javascript" src="__static__/admin/js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="__static__/admin/js/select-ui.min.js"></script>
 
<script type="text/javascript">
$(document).ready(function(e) {
    $(".select1").uedSelect({
		width : 345			  
	});
	$(".select2").uedSelect({
		width : 167  
	});
	$(".select3").uedSelect({
		width : 100
	});
});
</script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">系统设置</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    <div class="tools">
    
        <ul class="toolbar">
            <li onclick="deleteAllRedenvelopesCode()"><span><img src="__static__/admin/images/t03.png" /></span>删除</li>
        </ul>
    </div>
    <div id="usual1" class="usual"> 
    
  	<div id="" class="tabson">
    
    
            <form method="get" action="{:url('code')}" >

            <ul class="seachform">
        
                <li>
                    <label>搜索领取者</label><input type="text" name="Uname" value="{$Uname}" class="scinput" />
                </li>
                <li>
                    <label>搜索发出者</label><input type="text" name="Pname" value="{$Pname}" class="scinput" />
                </li>
                <li>
                    <label>搜索红包ID</label><input type="text" name="Redid" value="{$Redid}" class="scinput" />
                </li>
                
                <li>
                    <label>创建时间</label><input name="StarAddTime" type="date" class="scinput" value="{$StarAddTime}"/>-<input name="EndAddTime" type="date" class="scinput" value="{$EndAddTime}"/>
                </li>
                <li><label>&nbsp;</label><input type="submit" class="scbtn" value="查询"/></li>   
            </ul>
        </form>
    
    
    <table class="tablelist">
    	<thead>
    	<tr>
        <th><input name="checkboxs" type="checkbox" value=""/></th>
        <th>红包编号<i class="sort"><img src="__static__/admin/images/px.gif" /></i></th>
        <th>发出者</th>
        <th>领取者</th>
        <th>领取金额</th>
        <th>领取时间</th>
        <th>操作</th>
        </tr>
        </thead>
        <tbody>
          {foreach $redenvelopes_code_list as $v}
          <tr>
            <td><input name="checkbox" type="checkbox" value="{$v.id}" /></td>
            <td>{$v.Redenvelopes_id}</td>
            <td>{$v.Publisher}</td>
            <td>{$v.Recipients}</td>
            <td>{$v.Amount}</td>
            <td>{:date('Y-m-d H:i:s',$v.Addtime)}</td>
            <td>    
              <a href="javascript:;deleteRedenvelopesCode({$v.id})" class="tablelink"> 删除</a>
            </td>
          </tr> 
          {/foreach}
        </tbody>
    </table>
    
   
  
    
    </div>  
       
	</div>   
  </div>

     <div class="pagin">
    	<div class="message">共<i class="blue">{$pageListr->total()}</i>条记录，当前显示第&nbsp;<i class="blue">{$pageListr->currentPage()}&nbsp;</i>页</div>
        {$pageListr->render()}
    </div>
</body>
</html>
 
	<script type="text/javascript"> 
    checkboxs = $('input[name="checkboxs"]');
    checkbox = $("input[name='checkbox']");
    function deleteRedenvelopesCode(id){
        if(!confirm('确认删除此记录？')) return false;
        $.post('{:url("deleteRedenvelopesCode")}',{id:id},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    }
    function deleteAllRedenvelopesCode(){
        if(!confirm('是否删除所有选中的记录？')) return false;
         var ids=0;  
        checkbox.each(function() {  
            if ($(this).is(':checked')) {  
                ids += ","+$(this).val();  
            }  
        });  
       $.post('{:url("deleteRedenvelopesCode")}',{id:ids},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    } 
    checkboxs.click(function(){
        if($(this).is(':checked')){
             checkbox.attr('checked',true);
        }else{
             checkbox.attr('checked',false);
        }
    })
    checkbox.click(function(){
        var ck = $("input[name='checkbox']").length;
        var cm = $("input[type='checkbox']:checked").length;
        $(this).each(function(){
              if(!$(this).is(':checked') || ck != cm){
                  checkboxs.attr('checked',false);
              }else{
                  checkboxs.attr('checked',true);
            }
          }
        )
    })

	</script>
